(function (window) {
  function Model() {
    this.data = [
      {
        id: "1",
        value: "计划任务1",
        completed: false,
      },
      {
        id: "2",
        value: "计划任务2",
        completed: true,
      },
    ];
  }

  Model.prototype.getAll = function () {
    return this.data;
  };

  Model.prototype.add = function (val) {
    let item = {
      id: new Date().getTime(),
      value: val,
    };
    this.data.push(item);
    return this.data;
  };

  Model.prototype.remove = function (id) {
    let index = this.data.findIndex((item) => item.id === id);
    this.data.splice(index, 1);
    return this.data;
  };
  window.Model = Model;
})(window);
